/*
 *  Copyright 2013 Utkin Dmitry
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef PROTOQTRPC_RPCSERVER_H
#define PROTOQTRPC_RPCSERVER_H

#include <string>

namespace google {
namespace protobuf {
class Service;
}
}

class QString;

namespace protoqtrpc
{

/**
 * @brief The abstract RpcServer class
 */
class RpcServer
{
public:
    /**
     * @brief Destroys rpc server class
     */
    inline virtual ~RpcServer() {}

    /**
     * @brief Registers the service and add it into services list
     * @param service Service to register
     * @return true if service was sucessfully registered
     */
    virtual bool registerService(::google::protobuf::Service* service) = 0;

    /**
     * @brief Gets registered service by full qualified name
     * @param serviceName Full qualified service name
     * @return Pointer to found Service or NULL, if no service found
     */
    virtual ::google::protobuf::Service* getService(const std::string& serviceName) = 0;

    /**
     * @brief Try to start server, if server is not started check the errorString()
     * @return true if server was started successfully
     * @sa errorString()
     */
    virtual bool start() = 0;

    /**
     * @brief Stops the started server
     */
    virtual void stop() = 0;

    /**
     * @brief Get last error string
     * @return last error string
     */
    virtual QString errorString() const = 0;

};

}

#endif
